package com.hjc.config;

import com.hjc.aop.ResponseResultInterceptor;
import com.hjc.dto.CommonConstants;
import com.hjc.dto.SystemConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ResourcesConfig implements WebMvcConfigurer {

    @Autowired
    ResponseResultInterceptor responseResultInterceptor;


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /** 本地文件上传路径 */
        registry.addResourceHandler(CommonConstants.RESOURCE_PREFIX + "/**")
                .addResourceLocations("file:" + SystemConstants.getProfile() + "/");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(responseResultInterceptor);
    }
}
